home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / pmake / RCS / pmake.man,v < prev   
Encoding:
Text File  |  1991-10-07  |  53.8 KB  |  1,725 lines

  1. head     1.7;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @@;
  7.  
  8.  
  9. 1.7
  10. date     91.10.06.20.53.56;  author kupfer;  state Exp;
  11. branches ;
  12. next     1.6;
  13.  
  14. 1.6
  15. date     91.02.04.13.55.09;  author kupfer;  state Exp;
  16. branches ;
  17. next     1.5;
  18.  
  19. 1.5
  20. date     91.02.04.13.54.38;  author kupfer;  state Exp;
  21. branches ;
  22. next     1.4;
  23.  
  24. 1.4
  25. date     90.08.02.14.06.34;  author douglis;  state Exp;
  26. branches ;
  27. next     1.3;
  28.  
  29. 1.3
  30. date     90.06.28.22.31.48;  author douglis;  state Exp;
  31. branches ;
  32. next     1.2;
  33.  
  34. 1.2
  35. date     90.06.26.22.08.36;  author douglis;  state Exp;
  36. branches ;
  37. next     1.1;
  38.  
  39. 1.1
  40. date     90.02.17.17.15.23;  author douglis;  state Exp;
  41. branches ;
  42. next     ;
  43.  
  44.  
  45. desc
  46. @man page for pmake
  47. @
  48.  
  49.  
  50. 1.7
  51. log
  52. @Briefly explain the different debug options.
  53. @
  54. text
  55. @'\" $Id: pmake.man,v 1.6 91/02/04 13:55:09 kupfer Exp Locker: kupfer $ SPRITE (Berkeley)
  56. .de Pm
  57. .ie \\n(.$ .IR PMake \\$1
  58. .el .I PMake
  59. ..
  60. .if n .nr #D 3n
  61. .if t .nr #D .5i
  62. .if n .ds -> \->
  63. .if t .ds -> \(->
  64. .de DS   \" Real Display-Start macro. It actually works!
  65. .sp .5v
  66. .nf
  67. .in +\\n(#Du
  68. ..
  69. .de DE   \" Real Display-End macro.
  70. .in
  71. .fi
  72. .sp .5v
  73. ..
  74. .so \*(]ltmac.sprite
  75. .HS PMAKE cmds "4 February 1991"
  76. .BS
  77. .SH NAME
  78. pmake \- create programs in parallel
  79. .SH SYNOPSIS
  80. .HP
  81. .fi
  82. .B pmake
  83. [\c
  84. .B \-b\c
  85. ] [\c
  86. .B \-d
  87. .I what\c
  88. ] [\c
  89. .B \-f
  90. .I makefile\c
  91. ] [\c
  92. .B \-h\c
  93. ] [\c
  94. .B \-i\c
  95. ] [\c
  96. .B \-k\c
  97. ] [\c
  98. .B \-l\c
  99. ] [\c
  100. .B \-n\c
  101. ] [\c
  102. .B \-p
  103. .I #\c
  104. ] [\c
  105. .B \-q\c
  106. ] [\c
  107. .B \-r\c
  108. ] [\c
  109. .B \-s\c
  110. ] [\c
  111. .B \-t\c
  112. ] [\c
  113. .B \-v\c
  114. ] [\c
  115. .B \-x\c
  116. ] [\c
  117. .B \-B\c
  118. ] [\c
  119. .B \-C\c
  120. ] [\c
  121. .B \-D
  122. .I variable\c
  123. ] [\c
  124. .B \-I
  125. .I directory\c
  126. ] [\c
  127. .B \-J
  128. .I #\c
  129. ] [\c
  130. .B \-L
  131. .I #\c
  132. ] [\c
  133. .B \-M\c
  134. ] [\c
  135. .B \-P\c
  136. ] [\c
  137. .B \-R\c
  138. ] [\c
  139. .B \-V\c
  140. ] [\c
  141. .B \-W\c
  142. ] [\c
  143. .B \-X\c
  144. ] [\c
  145. .IB VAR1 = value1\c
  146. ] [\c
  147. .IB VAR2 = value2 ...\c
  148. ] [\c
  149. .I targ1\c
  150. ] [\c
  151. .I targ2 ...\c
  152. ]
  153. .BE
  154. .AR
  155. .AS \-I directory
  156. .AP \-b "\&"
  157. ``Background'' -- run all remote processes at low priority.  See also 
  158. the .BACKGROUND attribute.
  159. .AP \-d what
  160. Specify what modules should print debugging information.
  161. .I what
  162. is a string of letters from the following set: 
  163. .B a 
  164. (archives), 
  165. .B c
  166. (conditionals), 
  167. .B d 
  168. (directory searching), 
  169. .B j 
  170. (jobs), 
  171. .B m
  172. (make), 
  173. .B p
  174. (parsing), 
  175. .B r
  176. (remote), 
  177. .B s
  178. (suffixes),
  179. .B t
  180. (targets), 
  181. .B v
  182. (variables).  Use
  183. .B -d jr
  184. to find out what host each job is run on.
  185. .AP \-f makefile
  186. Specify a different makefile to read than the standard
  187. ``Makefile'' or ``makefile''.  If
  188. .I makefile
  189. is "-", reads from standard input.
  190. .AP \-h "\&"
  191. Prints out help information.
  192. .AP \-i "\&"
  193. ``Ignore errors'' -- ignore non-zero exit statuses of commands.
  194. .AP \-k "\&"
  195. ``Keepgoing'' -- if an error is encountered,
  196. keep working on those parts of the input graph that are not affected by the
  197. error.
  198. .AP \-l "\&"
  199. PMake has the ability to lock a directory against other
  200. people executing it in the same directory (by means of a file called
  201. ``LOCK.make'' that it creates and checks for in the directory). This
  202. is a Good Thing because two people doing the same thing in the same place
  203. can be disastrous for the final product (too many cooks and all that).
  204. Whether this locking is the default is up to your system
  205. administrator. If locking is on,
  206. .B \-l
  207. will turn it off, and vice versa. Note that this locking will not
  208. prevent \fIyou\fP from invoking PMake twice in the same place -- if
  209. you own the lock file, PMake will warn you about it but continue to execute.
  210. .AP \-n "\&"
  211. ``No execute'' -- do not execute commands.
  212. Just print the ones that would be executed.
  213. .AP \-p "#"
  214. Tell
  215. .Pm
  216. if and when to print the input graph.
  217. The number is the bitwise OR of the numbers 1 and 2 with 1 meaning to print the
  218. graph before making anything and 2 meaning to print the graph after making
  219. everything.
  220. If no number is given,
  221. it defaults to 3.
  222. .AP \-q "\&"
  223. ``Query'' -- do not execute any commands.
  224. Just exit 0 if the given target(s) is (are) up to date and exit non-zero
  225. otherwise.
  226. .AP \-r "\&"
  227. ``Remove built-in rules'' -- do not parse the built-in rules given in
  228. the system makefile.
  229. .AP \-s "\&"
  230. ``Silence'' -- do not echo commands as they are executed.
  231. .AP \-t "\&"
  232. ``Touch targets'' -- rather than executing the commands to create a target,
  233. just change its modification time so it appears up-to-date.
  234. This is dangerous.
  235. .AP \-v "\&"
  236. ``System V'' -- invokes compatibility functions suitable for acting
  237. like the System V version of Make. This implies
  238. .AP \-x "\&"
  239. ``Export judiciously -- run commands locally in preference to running them 
  240. remotely.  By default, PMake will only run locally
  241. if there are more commands to execute than idle hosts available; with
  242. this option,  
  243. PMake will run one command locally and export additional
  244. commands to available hosts.
  245. .B \-B ,
  246. and
  247. .B \-V 
  248. and turns off directory locking. Locking may be turned back on again
  249. by giving the
  250. .B \-l
  251. flag after
  252. .B \-v .
  253. .AP \-B "\&"
  254. ``Backwards-compatible'' -- performs as much like Make as possible
  255. (including executing a single shell per command and expanding
  256. variables as Make did) while still performing in parallel.
  257. .AP \-C "\&"
  258. ``Non-compatible'' -- turns off all compatibility specified up to the point at
  259. which
  260. .B \-C
  261. is encountered.
  262. .AP \-D variable
  263. Defines the given variable to be
  264. .B 1
  265. in the global context.
  266. .AP \-I directory
  267. Specify another directory in which to look for #include'd makefiles.
  268. This flag may be repeated as many times as necessary.
  269. .AP \-J #
  270. Specify the maximum number of jobs to run at once on all machines.
  271. .AP \-L #
  272. Specify the maximum number of jobs to run locally.
  273. .AP \-M "\&"
  274. Be as much like Make as possible. No parallel execution. Old-style
  275. variable expansion. One shell per command. Etc.
  276. .AP \-P "\&"
  277. ``Don't use Pipes'' -- see the section on
  278. .AP \-R "\&"
  279. ``Remigrate verbosely'' -- announce when processes are remigrated
  280. subsequent to eviction.
  281. .BR OUTPUT .
  282. .AP \-V "\&"
  283. ``Do old-style variable expansion'' -- expands an unknown variable to
  284. the empty string.
  285. .AP \-W "\&"
  286. Don't print warning messages.
  287. .AP \-X "\&"
  288. ``No Export'' -- prohibits exportation. 
  289. .AP VAR=value "\&"
  290. Set the value of the variable
  291. .B VAR
  292. to the given value.
  293. This supercedes any value assigned to the variable in the makefile.
  294. See
  295. .BR VARIABLES .
  296. .SH DESCRIPTION
  297. .PP
  298. .Pm
  299. is a program designed to make the maintenance of other programs much
  300. easier.  Its input is a ``makefile'' that specifies which files depend
  301. on which other files and what to do about files that are
  302. ``out-of-date.''
  303. If you don't specify a makefile to read,
  304. .B Makefile
  305. and
  306. .BR makefile ,
  307. in that order,
  308. are looked for and read if they exist.
  309. .PP
  310. This manual page is meant to be a reference page only. For a more
  311. thorough description of
  312. .Pm ,
  313. please refer to
  314. .I PMake -- A Tutorial\c
  315. (available in this distribution).
  316. .PP
  317. There are four basic types of lines in a makefile:
  318. .RS
  319. .IP 1)
  320. File dependency specifications
  321. .IP 2)
  322. Creation commands
  323. .IP 3)
  324. Variable assignments
  325. .IP 4)
  326. Comments,
  327. include statements and conditional directives
  328. .RE
  329. .PP
  330. Any line may be continued over multiple lines by ending it with a backslash.
  331. The backslash,
  332. following newline and any initial whitespace on the following line are
  333. compressed into a single space.
  334. .SH DEPENDENCY LINES
  335. .PP
  336. On a dependency line, there are targets, sources and an operator.
  337. The targets ``depend'' on the sources and are usually created from them.
  338. Any number of targets and sources may be specified on a dependency
  339. line. All the targets in the line are made to depend on all the sources.
  340. If you run out of room, use a backslash at the end of the line to
  341. continue onto the next one.
  342. .PP
  343. Any file may be a target and any file may be a source, but the relationship
  344. between them is determined by the ``operator''
  345. that separates them. Three operators are defined:
  346. .RS
  347. .IP ":"
  348. A target on the line is considered ``out-of-date''
  349. if any of its sources has been modified
  350. more recently than the target. Sources for a target accumulate over
  351. lines when this operator is used.
  352. .IP "!"
  353. Targets will always be re-created, but this will not happen until all
  354. of its sources have been examined and re-created, if necessary.
  355. Sources accumulate over lines as for the colon.
  356. .IP "::"
  357. Much like the colon, but acts like the ! operator if no sources are
  358. specified. In addition sources do not accumulate over lines. Rather,
  359. the commands associated with the line (see below) are executed only if
  360. the target is out-of-date with respect to the sources on that line only.
  361. In addition, the target will not be removed if
  362. .Pm
  363. is interrupted, unlike for the other two operators.
  364. .RE
  365. .PP
  366. For example:
  367. .DS
  368. a    : a.o b.o c.o
  369. b    ! d.o e.o
  370. c    :: f.o
  371.     command1
  372. a    : g.o
  373. b    ! h.o
  374. c    ::
  375.     command2
  376. .DE
  377. specifies that a depends on a.o, b.o, c.o and g.o and will be remade
  378. only if out-of-date with respect to these four files. b depends on
  379. d.o, e.o and h.o and will always be remade, but only after these three
  380. files have been remade. c will be remade with command1 if it is
  381. out-of-date with respect to f.o, as for the colon operator, while
  382. command2 will always be executed.
  383. .PP
  384. Targets and sources may also contain standard shell wildcard
  385. characters (?, *, [ and {}), but the ?, *, [ and ] characters may only
  386. be used in the final component of the target or source. If a target or
  387. source contains only curly braces and no other wildcard characters, it
  388. need not describe an existing file. Otherwise, only existing files
  389. will be used. E.g. the pattern
  390. .DS
  391. {a,b,c}.o
  392. .DE
  393. will expand to
  394. .DS
  395. a.o b.o c.o
  396. .DE
  397. regardless of whether these three files exist, while
  398. .DS
  399. [abc].o
  400. .DE
  401. will only expand to this if all three files exist. The resulting
  402. expansion is in directory order, not alphabetically sorted as in the shell.
  403. .SH COMMANDS
  404. .PP
  405. Each target has associated with it a sort of shell script made up of a
  406. series of shell commands. The creation script for a target should
  407. immediately follow the dependency line for that target.
  408. Each of the commands in this script
  409. .I must
  410. be preceded by a tab character. 
  411. .PP
  412. While any given target
  413. may appear on more than one dependency line, only one of these dependency lines
  414. may be followed by a creation script, unless the "::" operator is used.
  415. .PP
  416. One helpful feature of
  417. .Pm
  418. is the ability to squirrel away commands for a target to be executed when
  419. everything else has been done. To do this, make one of the commands
  420. for the target be just ``...'' (an ellipsis) on a line by itself. The
  421. ellipsis itself won't be executed, of course, but any commands in the
  422. target's script that follow the ellipsis will be saved until
  423. .Pm
  424. is done processing everything it needs to process.
  425. If you were to say,
  426. .DS
  427. a.o             : a.c
  428.         cc -c a.c
  429.         ...
  430.         @@echo "All done"
  431. .DE
  432. Then the command ``echo "All done"'' would execute once everything
  433. else had finished. Note that this will only happen if ``a.o'' is found
  434. to be out-of-date.
  435. .PP
  436. There is another way in which makefile shell commands differ from
  437. regular shell commands, as illustrated in the above makefile scrap.
  438. The first two characters after the initial tab (and any other
  439. whitespace) are treated specially. If they are any combination of `@@'
  440. and `\-', (``@@'', ``@@\-'', ``\-@@'' or ``\-''), they cause
  441. .Pm
  442. to do different things.
  443. .PP
  444. In most cases, shell commands are printed to
  445. the screen before they're actually executed. This is to keep you
  446. informed of what's going on. If an `@@' appears, however, this echoing
  447. is suppressed. In the case of the echo command, above, this makes
  448. sense. It would look silly to see
  449. .DS
  450. echo "All done"
  451. All done
  452. .DE
  453. so
  454. .Pm
  455. allows you to avoid that (this sort of echo control is
  456. only available if you use the Bourne or C shells to execute your
  457. commands, since the commands are echoed by the shell,
  458. not by
  459. .Pm ).
  460. .PP
  461. The other special character is the `\-'.  Shell commands exit with a
  462. certain ``exit status.''  Normally this status will be 0 if everything
  463. went ok and non-zero if something went wrong. For this reason,
  464. .Pm
  465. will consider an error to have occurred if one of the commands it
  466. invokes returns a non-zero status. When it detects an error, its usual
  467. action is to stop working, wait for everything in process to finish,
  468. and exit with a non-zero status itself.  This behavior can be altered,
  469. however, by means of
  470. .B \-i
  471. or
  472. .B \-k
  473. arguments, or by placing a `\-' at the
  474. front of the command.
  475. (Another quick note: the decision of whether to abort a target when
  476. one of its shell commands returns non-zero is left to the shell that
  477. is executing the commands. Some shells allow this ``error-checking''
  478. to be switched on and off at will while others do not.)
  479. .SH VARIABLES
  480. .PP
  481. .Pm
  482. has the ability to save text in variables to be recalled later at your
  483. convenience.  Variables in
  484. .Pm
  485. are used much like variables in
  486. .IR sh (1)
  487. and, by tradition, consist of all upper-case letters.
  488. They are assigned- and appended-to using lines of the form
  489. .DS
  490. \fIVARIABLE\fP \fB=\fP \fIvalue\fP
  491. \fIVARIABLE\fP \fB+=\fP \fIvalue\fP
  492. .DE
  493. respectively, while being conditionally assigned-to (if not already
  494. defined) and assigned-to with expansion by lines of the form
  495. .DS
  496. \fIVARIABLE\fP \fB?=\fP \fIvalue\fP
  497. \fIVARIABLE\fP \fB:=\fP \fIvalue\fP
  498. .DE
  499. Finally, 
  500. .DS
  501. \fIVARIABLE\fP \fB!=\fP \fIcommand\fP
  502. .DE
  503. will execute
  504. .I command
  505. using the Bourne shell and place the result in the given variable.
  506. Newlines are converted to spaces before the assignment is made. This
  507. is not intended to be used with commands that produce a large amount
  508. of output. If you use it this way, it will probably deadlock.
  509. .PP
  510. Variables are expanded by enclosing the variable name in either
  511. parentheses or curly braces and preceding the whole thing with a
  512. dollar sign.  E.g. to set the variable
  513. .B CFLAGS
  514. to the string ``\-I/sprite/src/lib/libc \-O'' you would place a line
  515. .DS
  516. CFLAGS = \-I/sprite/src/lib/libc \-O
  517. .DE
  518. in the makefile and use the word
  519. .B $(CFLAGS)
  520. wherever you would like the string ``\-I/sprite/src/lib/libc \-O'' to
  521. appear.  To pass a string of the form ``$(\fIname\fP)'' or
  522. ``${\fIname\fP}'' through to the shell (e.g. to tell it to substitute
  523. one of its variables),
  524. you can use ``$$(\fIname\fP)'' and ``$${\fIname\fP}'',
  525. respectively, 
  526. or,
  527. as long as the \fIname\fP is not a
  528. .Pm
  529. variable,
  530. you can just place the string in directly, as
  531. .Pm
  532. will not expand a variable it doesn't know, unless it is given one of
  533. the three compatibility flags
  534. .BR \-V ,
  535. .BR \-B ,
  536. or
  537. .BR \-M .
  538. .PP
  539. There are two distinct times at which variable substitution occurs:
  540. When parsing a dependency line,
  541. such substitution occurs immediately upon reading the line.
  542. Thus all variables used in dependency lines must be defined before
  543. they appear on any dependency line.
  544. For variables that appear in shell commands,
  545. variable substitution occurs when the command is processed,
  546. i.e. when it is prepared to be passed to the shell or before being
  547. squirreled away for later execution (qv. \fBCOMMANDS\fP, above).
  548. .PP
  549. There are four different types of variables at which
  550. .Pm
  551. will look when trying to expand any given variable.
  552. They are (in order of decreasing precedence): (1) variables that are
  553. defined specific to a certain target. These are the so-called
  554. ``local'' variables and will only be used when performing variable
  555. substitution on the target's shell script and in dynamic sources (see below
  556. for more details), (2) variables that were defined on the command line,
  557. (3) variables defined in the makefile and (4) those defined in
  558. .Pm 's
  559. environment, as passed by your login shell.
  560. An important side effect of this searching order is that once you
  561. define a variable on the command line, nothing in the makefile can
  562. change it. \fINothing.\fP
  563. .PP
  564. As mentioned above,
  565. each target has associated with it as many as seven ``local''
  566. variables. Four of these variables are always set for every target
  567. that must be re-created. Each local variable has a long, meaningful
  568. name and a short, one-character name that exists for backwards-compatibility.
  569. They are:
  570. .RS
  571. .IP ".TARGET (@@)"
  572. The name of the target.
  573. .IP ".OODATE (?)"
  574. The list of sources for this target that were deemed out-of-date.
  575. .IP ".ALLSRC (>)"
  576. The list of all sources for this target.
  577. .IP ".PREFIX (*)"
  578. The file prefix of the file. This contains only the file portion -- no
  579. suffix or leading directory components.
  580. .RE
  581. .PP
  582. Three other ``local'' variables are set only for certain targets under
  583. special circumstances. These are the ``.IMPSRC'', ``.ARCHIVE''
  584. and ``.MEMBER'' variables. When
  585. they are set, how they are used, and what their short forms are are detailed
  586. in later sections.
  587. .PP
  588. In addition, for you System V fans, the six variables ``@@F'', ``@@D'',
  589. ``<F'', ``<D'', ``*F'', and ``*D'' are defined to be the same as for the
  590. System V version of Make. If you don't know about these things, be glad.
  591. .PP
  592. Four of these local variables may be used in sources on dependency
  593. lines. The variables expand to the proper value for each target on the
  594. line. The variables are ``.TARGET'', ``.PREFIX'', ``.ARCHIVE'', and
  595. ``.MEMBER''.
  596. .PP
  597. In addition, certain variables are set by or have special meaning to
  598. .Pm .
  599. The
  600. .B .PMAKE
  601. (and
  602. .BR MAKE )
  603. variable is set to the name by which
  604. .Pm
  605. was invoked, to allow recursive makes to use the same version,
  606. whatever it may be.
  607. All command-line flags given to
  608. .Pm
  609. are stored in the
  610. .B .MAKEFLAGS
  611. (and
  612. .BR MFLAGS )
  613. variable just as they were given. This variable is also exported to
  614. subshells as the
  615. .B PMAKE
  616. environment variable.
  617. .PP
  618. Variable expansion may be modified as for the C shell. A general
  619. expansion specification looks like:
  620. .DS
  621. \fB$(\fP\fIvariable\fP[\fB:\fP\fImodifier\fP[\fB:\fP...]]\fB)\fP
  622. .DE
  623. Each modifier begins with a single character, thus:
  624. .RS
  625. .IP "M\fIpattern\fP"
  626. This is used to select only those words (a word is a series of
  627. characters that are neither spaces nor tabs) that match the given
  628. .I pattern .
  629. The pattern is a wildcard pattern like that used by the shell, where "*"
  630. means 0 or more characters of any sort; "?" is any single character;
  631. "[abcd]" matches any single character that is either `a', `b', `c' or `d'
  632. (there may be any number of characters between the brackets);
  633. .B [0-9]
  634. matches any single character that is between `0' and `9' (i.e. any
  635. digit. This form may be freely mixed with the other bracket form), and
  636. \&\e is used to escape any of the characters "*", "?", "[" or ":",
  637. leaving them as regular characters to match themselves in a word.
  638. .IP "N\fIpattern\fP"
  639. This is identical to ":M" except it substitutes all words that don't
  640. match the given pattern.
  641. .IP "S/\fIsearch-string\fP/\fIreplacement-string\fP/[g]"
  642. Causes the first occurrence of
  643. .I search-string
  644. in the variable to be replaced by
  645. .I replacement-string ,
  646. unless the "g"
  647. flag is given at the end, in which case all occurrences of the string
  648. are replaced. The substitution is performed on each word in the
  649. variable in turn. If 
  650. .I search-string
  651. begins with a "^",
  652. the string must match starting at the beginning of the word. If
  653. .I search-string
  654. ends with a "$",
  655. the string must match to the end of the word (these two may be
  656. combined to force an exact match). If a backslash precedes these two
  657. characters, however, they lose their special meaning. Variable
  658. expansion also occurs in the normal fashion inside both the
  659. .I search-string
  660. and the
  661. .I replacement-string ,
  662. .B except
  663. that a backslash is used to prevent the expansion of a "$",
  664. not another dollar sign, as is usual.
  665. Note that
  666. .I search-string
  667. is just a string, not a pattern, so none of the usual
  668. regular-expression/wildcard characters has any special meaning save "^"
  669. and "$".
  670. In the replacement string,
  671. the "&"
  672. character is replaced by the
  673. .I search-string
  674. unless it is preceded by a backslash.
  675. You are allowed to use any character except
  676. colon or exclamation point to separate the two strings. This so-called
  677. delimiter character may be placed in either string by preceding it
  678. with a backslash.
  679. .IP T
  680. Replaces each word in the variable expansion by its last
  681. component (its ``tail''). 
  682. .IP H
  683. This is similar to ":T",
  684. except that every word is replaced by everything but the tail (the
  685. ``head''). 
  686. .IP E
  687. ":E" replaces each word by its suffix (``extension'').
  688. .IP R
  689. This replaces each word by everything but the suffix (the ``root'' of
  690. the word).
  691. .RE
  692. .PP
  693. In addition, PMake supports the System V form of substitution
  694. (\fIstring1\fP=\fIstring2\fP). 
  695. .SH COMMENTS, INCLUSION AND CONDITIONALS
  696. .PP
  697. Makefile inclusion and conditional structures reminiscent of
  698. the C compiler have also been included in
  699. .Pm .
  700. .PP
  701. Comments begin with a `#' anywhere but in a shell command and continue
  702. to the end of the line.
  703. If the `#' comes at the beginning of the line, however, the following
  704. keywords are recognized and acted on:
  705. .SS include ''\fImakefile\fP''
  706. .SS include <\fIsystem makefile\fP>
  707. .PP
  708. This is very similar to the C compiler's file-inclusion facility,
  709. right down to the syntax.  What follows the
  710. .B #include
  711. must be a filename enclosed either in double-quotes or angle brackets.
  712. Variables will be expanded between the double-quotes or
  713. angle-brackets.  If angle-brackets are used, the system makefile
  714. directory is searched.  If the name is enclosed in double-quotes, the
  715. including makefile's directory, followed by all directories given via
  716. .B \-I
  717. arguments, followed by the system directory, is searched for a
  718. file of the given name.
  719. .PP
  720. If the file is found,
  721. .Pm
  722. starts taking input from that file as if it were part of the original
  723. makefile.
  724. .PP
  725. When the end of the file is reached,
  726. .Pm
  727. goes back to the previous file and continues from where it left off.
  728. This facility is recursive up to a depth limited only by the number of open
  729. files allowed to any process at one time.
  730. .SS "if [!] \fIexpr\fP [ \fIop\fP \fIexpr\fP ... ]"
  731. .SS ifdef [!] \fIvariable\fP [\fIop\fP \fIvariable\fP...]
  732. .SS ifndef [!] \fIvariable\fP [\fIop\fP \fIvariable\fP...]
  733. .SS ifmake [!] \fItarget\fP [\fIop\fP \fItarget\fP...]
  734. .SS ifnmake [!] \fItarget\fP [\fIop\fP \fItarget\fP...]
  735. .PP
  736. These are all the beginnings of conditional constructs in the spirit of
  737. the C compiler.
  738. Conditionals may be nested to a depth of thirty.
  739. .PP
  740. In the expressions given above,
  741. .I op
  742. may be either \fB||\fP (logical \s-2OR\s0) or \fB&&\fP (logical
  743. \s-2AND\s0).
  744. .B &&
  745. has a higher precedence than
  746. .BR || .
  747. As in C,
  748. .Pm
  749. will evaluate an expression only as far as necessary to determine its
  750. value. I.e. if the left side of an
  751. .B &&
  752. is false, the expression is false and vice versa for
  753. .BR || .
  754. Parentheses may be used as usual to change the order of evaluation.
  755. .PP
  756. One other boolean operator is provided: \fB!\fP (logical negation). It
  757. is of a higher precedence than either the \s-2AND\s0 or \s-2OR\s0 operators,
  758. and may be applied in any of the ``if'' constructs,
  759. negating the given function for ``#if'' or the implicit function for
  760. the other four.
  761. .PP
  762. .I Expr
  763. can be one of several things. Four functions are provided, each of
  764. which takes a different sort of argument. 
  765. .PP
  766. The function
  767. .B defined
  768. is used to test for the existence of a variable.
  769. Its argument is, therefore, a variable name.
  770. Certain lower-case variable names (e.g. ``sun'', ``unix'' and
  771. ``sprite'') are defined in the system makefile (qv. \fBFILES\fP) to
  772. specify the sort of system on which
  773. .Pm
  774. is being run. These are intended to make makefiles more portable.
  775. Any variable may be used as the argument of the
  776. .B defined
  777. function.
  778. .PP
  779. The
  780. .B make
  781. function is given the name of a target in the makefile and evaluates
  782. to true if the target was given on
  783. .Pm 's
  784. command-line or as a source for the
  785. .B .MAIN
  786. target before the line containing the conditional.
  787. .PP
  788. The
  789. .B exists
  790. function takes a file name, which file is searched for on the system
  791. search path (as defined by
  792. .B .PATH
  793. targets (see below)). It evaluates true if the file is found.
  794. .PP
  795. .B empty
  796. takes a variable expansion specification (minus the dollar sign) as
  797. its argument. If the resulting expansion is empty, this evaluates
  798. true.
  799. .PP
  800. .I Expr
  801. can also be an arithmetic or string comparison, with the lefthand side
  802. being a variable expansion. The standard C relational operators are
  803. allowed, and the usual number/base conversion is performed, with the
  804. exception that octal numbers are not supported. If the righthand side
  805. of a "==" or "!=" operator begins with a quotation mark, a string
  806. comparison is done between the expanded variable and the text between
  807. the quotation marks.  If no relational operator is given, it is
  808. assumed that the expanded variable is to be compared against 0, i.e.
  809. it is interpreted as a boolean, with a 0 value being false and a
  810. non-zero value being true.
  811. .PP
  812. When, in the course of evaluating one of these conditional
  813. expressions,
  814. .Pm
  815. encounters some word it does not recognize, it applies one of either
  816. .I make
  817. or
  818. .I defined
  819. to it, depending on the form of ``if'' used. E.g. ``#ifdef'' will
  820. apply the
  821. .I defined
  822. function, while ``#ifnmake'' will apply the negation of the
  823. .I make
  824. function.
  825. .PP
  826. If the expression following one of these forms evaluates true, the
  827. reading of the makefile continues as before. If it evaluates false,
  828. the following lines are skipped. In both cases, this continues until
  829. either an
  830. .B #else
  831. or an
  832. .B #endif
  833. line is encountered.
  834. .SS else
  835. .PP
  836. The #else,
  837. as in the C compiler,
  838. causes the sense of the last conditional to be inverted and the reading of
  839. the makefile to be based on this new value.
  840. I.e. if the previous expression evaluated true,
  841. the parsing of the makefile is suspended until an #endif line is read.
  842. If the previous expression evaluated false,
  843. the parsing of the makefile is resumed.
  844. .SS "elif [!] \fIexpr\fP [ \fIop\fP \fIexpr\fP ... ]"
  845. .SS elifdef [!] \fIvariable\fP [\fIop\fP \fIvariable\fP...]
  846. .SS elifndef [!] \fIvariable\fP [\fIop\fP \fIvariable\fP...]
  847. .SS elifmake [!] \fItarget\fP [\fIop\fP \fItarget\fP...]
  848. .SS elifnmake [!] \fItarget\fP [\fIop\fP \fItarget\fP...]
  849. .PP
  850. The ``elif'' constructs are a combination of ``else'' and ``if,'' as
  851. the name implies. If the preceding ``if'' evaluated false, the
  852. expression following the ``elif'' is evaluated and the lines following
  853. it are read or ignored the same as for a regular ``if.''
  854. If the preceding ``if'' evaluated true, however, the ``elif'' is
  855. ignored and all following lines until the ``endif'' (see below) are ignored.
  856. .SS endif
  857. .PP
  858. .B #endif
  859. is used to end a conditional section. If lines were being skipped, the
  860. reading of the makefile resumes. Otherwise, it has no effect (the
  861. makefile continues to be parsed as it was just before the
  862. .B #endif
  863. was encountered).
  864. .SS undef
  865. .PP
  866. Takes the next word on the line as a global variable to be undefined
  867. (only undefines global variables, not command-line variables). If the
  868. variable is already undefined, no message is generated.
  869. .SH TARGET ATTRIBUTES
  870. .PP
  871. In
  872. .Pm ,
  873. files can have certain ``attributes.''
  874. These attributes cause
  875. .Pm
  876. to treat the targets in special ways. An attribute is a special word
  877. given as a source to a target on a dependency line. 
  878. The words and their functions are given below:
  879. .nr pw \w'.EXPORTSAME  'u
  880. .IP .BACKGROUND \n(pwu
  881. Forces the target to be run at low priority, to keep it from
  882. preventing other higher-priority processes from using idle hosts.
  883. .IP .DONTCARE \n(pwu
  884. If a target is marked with this attribute and PMake can't figure out
  885. how to create it, it will ignore this fact and assume the file isn't
  886. really needed or actually exists and PMake just can't find it.
  887. .IP .EXEC \n(pwu
  888. This causes the marked target's shell script to always be executed
  889. (unless the
  890. .B \-n
  891. or
  892. .B \-t
  893. flag is given), but appear invisible to any targets that depend on it.
  894. .IP .EXPORT \n(pwu
  895. This is used to mark those targets whose creation should be sent to
  896. another machine if at all possible. This may be used by some
  897. exportation schemes if the exportation is expensive. You should ask
  898. your administrator if it is necessary.
  899. .IP .EXPORTSAME \n(pwu
  900. Tells the export system that the job should be exported to a machine
  901. of the same architecture as the current one. Certain operations (e.g.
  902. running text through
  903. "nroff")
  904. can be performed the same on any architecture (CPU and
  905. operating system type), while others (e.g. compiling a program with
  906. "cc")
  907. must be performed on a machine with the same architecture. Not all
  908. export systems will support this attribute.
  909. .IP .IGNORE \n(pwu
  910. Giving a target the
  911. .B .IGNORE
  912. attribute causes PMake to ignore errors from any of the target's commands, as
  913. if they all had `\-' before them.
  914. .IP .INVISIBLE \n(pwu
  915. This allows you to specify one target as a source for another without
  916. the one affecting the other's local variables.
  917. .IP .JOIN \n(pwu
  918. This forces the target's shell script to be executed only if one or more of the
  919. sources was out-of-date. In addition, the target's name,
  920. in both its
  921. .B .TARGET
  922. variable and all the local variables of any target that depends on it,
  923. is replaced by the value of its
  924. .B .ALLSRC
  925. variable.
  926. Another aspect of the .JOIN attribute is it keeps the target from
  927. being created if the
  928. .B \-t
  929. flag was given.
  930. .IP .MAKE \n(pwu
  931. The
  932. .B .MAKE
  933. attribute marks its target as being a recursive invocation of PMake.
  934. This forces PMake to execute the script associated with
  935. the target (if it's out-of-date) even if you gave the
  936. .B \-n
  937. or
  938. .B \-t
  939. flag.
  940. .IP .NOEXPORT \n(pwu
  941. Forces the target to be created locally, even if you've given
  942. .Pm
  943. the
  944. .B "\-L 0"
  945. flag.
  946. .IP .NOTMAIN \n(pwu
  947. Normally, if you do not specify a target to make in any other way,
  948. .Pm
  949. will take the first target on the first dependency line of a
  950. makefile as the target to create.
  951. Giving a target this attribute keeps it from this fate.
  952. .IP .PRECIOUS \n(pwu
  953. When PMake is interrupted, it
  954. will attempt to clean up after itself by removing any half-made
  955. targets. If a target has this attribute, however,
  956. .Pm
  957. will leave it alone
  958. .IP .SILENT \n(pwu
  959. Marking a target with this attribute keeps its commands from being
  960. printed when they're executed.
  961. .IP .USE \n(pwu
  962. By giving a target this attribute, you turn the target into 
  963. .Pm 's
  964. equivalent of a macro. When the target is used as a source for another target,
  965. the other target acquires the commands, sources and attributes (except
  966. .BR .USE )
  967. of the source.
  968. If the target already has commands, the
  969. .B .USE
  970. target's commands are added to the end. If more than one .USE-marked
  971. source is given to a target, the rules are applied sequentially.
  972. .SH SPECIAL TARGETS
  973. .PP
  974. As there were in Make, so there are certain targets that have special
  975. meaning to PMake. When you use one on a dependency line, it is the
  976. only target that may appear on the left-hand-side of the operator.
  977. The targets are as follows:
  978. .nr pw \w'.MAKEFLAGS  'u
  979. .IP .BACKGROUND \n(pwu
  980. applies the .BACKGROUND attribute to each of its 
  981. sources. If there are no sources on the
  982. dependency line, then it is as if you gave PMake the
  983. .B \-b
  984. flag.
  985. .IP .BEGIN \n(pwu
  986. .Ix 0 def .BEGIN
  987. Any commands attached to this target are executed before anything else
  988. is done. You can use it for any initialization that needs doing.
  989. .IP .DEFAULT \n(pwu
  990. This is sort of a .USE rule for any target (that was used only as a
  991. source) that
  992. .Pm
  993. can't figure out any other way to create. Only the shell script is used. The
  994. .B .IMPSRC
  995. variable of a target that inherits
  996. .B .DEFAULT 's
  997. commands is set to the target's own name.
  998. .IP .END \n(pwu
  999. This serves a function similar to
  1000. .BR .BEGIN :
  1001. commands attached to it are executed once everything has been
  1002. re-created (so long as no errors occurred). It also serves the extra
  1003. function of being a place on which PMake can hang commands you put off
  1004. to the end. Thus the script for this target will be executed before
  1005. any of the commands you save with the ``.\|.\|.''. 
  1006. .IP .EXPORT \n(pwu
  1007. The sources for this target are passed to the exportation system compiled
  1008. into
  1009. .Pm .
  1010. Some systems will use these sources to configure
  1011. themselves. You should ask your system administrator about this.
  1012. .IP .IGNORE \n(pwu
  1013. This target marks each of its sources with the
  1014. .B .IGNORE
  1015. attribute. If you don't give it any sources, then it is like
  1016. giving the
  1017. .B \-i
  1018. flag.
  1019. .IP .INCLUDES \n(pwu
  1020. The sources for this target are taken to be suffixes that indicate a
  1021. file that can be included in a program source file.
  1022. The suffix must have already been declared with
  1023. .B .SUFFIXES
  1024. (see below).
  1025. Any suffix so marked will have the directories on its search path
  1026. (see
  1027. .B .PATH ,
  1028. below) placed in the
  1029. .B .INCLUDES
  1030. variable, each preceded by a
  1031. .B \-I
  1032. flag. 
  1033. The
  1034. .B .h
  1035. suffix is already marked in this way in the system makefile.
  1036. .IP .INTERRUPT \n(pwu
  1037. When PMake is interrupted,
  1038. it will execute the commands in the script for this target, if it
  1039. exists. 
  1040. .IP .LIBS \n(pwu
  1041. This does for libraries what
  1042. .B .INCLUDES
  1043. does for include files, except the flag used is
  1044. .BR \-L ,
  1045. as required by those linkers that allow you to tell them where to find
  1046. libraries. The variable used is
  1047. .BR .LIBS .
  1048. .IP .MAIN \n(pwu
  1049. If you didn't give a target (or targets) to create when you invoked
  1050. PMake, it will take the sources of this target as the targets to
  1051. create.
  1052. .IP .MAKEFLAGS \n(pwu
  1053. This target provides a way for you to always specify flags for PMake
  1054. when the makefile is used. The flags are just as they would be typed
  1055. to the shell,
  1056. though the
  1057. .B \-f
  1058. and
  1059. .B \-r
  1060. flags have no effect.
  1061. .IP .NULL \n(pwu
  1062. This allows you to specify what suffix
  1063. .Pm
  1064. should pretend a file has if, in fact, it has no known suffix. Only
  1065. one suffix may be so designated. The last source on the dependency
  1066. line is the suffix that is used (you should, however, only give one
  1067. suffix.\|.\|.).
  1068. .IP .PATH \n(pwu
  1069. If you give sources for this target, PMake will take them as
  1070. directories to search for files it cannot find in the current
  1071. directory. If you give no sources, it will clear out any directories
  1072. added to the search path before. 
  1073. .IP .PATH\fIsuffix\fP \n(pwu
  1074. This does a similar thing to
  1075. .BR .PATH ,
  1076. but it does it only for files with the given suffix. The suffix must
  1077. have been defined already.
  1078. .IP .PRECIOUS \n(pwu
  1079. Gives the
  1080. .B .PRECIOUS
  1081. attribute to each source on the dependency line, unless there are no
  1082. sources, in which case the
  1083. .B .PRECIOUS
  1084. attribute is given to every target in the file.
  1085. .IP .RECURSIVE \n(pwu
  1086. Applies the
  1087. .B .MAKE
  1088. attribute to all its sources. It does nothing if you don't give it any sources.
  1089. .IP .SHELL \n(pwu
  1090. Tells
  1091. .Pm
  1092. to use some other shell than the Bourne Shell.
  1093. The sources for the target are organized as
  1094. \fIkeyword\fP\fB=\fP\fIvalue\fP strings. If a \fIvalue\fP contains
  1095. whitespace, it may be surrounded by double-quotes to make it a single
  1096. word. The possible sources are:
  1097. .RS
  1098. .IP "\fBpath=\fP\fIpath\fP"
  1099. Tells where the shell actually resides. If you specify this and nothing else, PMake will use the
  1100. last component of the path to find the specification. Use this if you just
  1101. want to use a different version of the Bourne or C Shell (PMake knows
  1102. how to use the C Shell too).
  1103. .IP "\fBname=\fP\fIname\fP"
  1104. This is the name by which the shell is to be known. It is a single
  1105. word and, if no other keywords are specified (other than
  1106. .BR path ),
  1107. it is the name by which PMake attempts to find a specification for the
  1108. it. You can use this if you would just rather use
  1109. the C Shell than the Bourne Shell (``\c
  1110. .BR ".SHELL: name=csh" ''
  1111. will do it).
  1112. .IP "\fBquiet=\fP\fIecho-off command\fP"
  1113. The command
  1114. .Pm
  1115. should send to stop the shell from printing its commands. Once echoing
  1116. is off, it is expected to remain off until explicitly turned on.
  1117. .IP "\fBecho=\fP\fIecho-on command\fP"
  1118. The command PMake should give to turn echoing back on again.
  1119. .IP "\fBfilter=\fP\fIprinted echo-off command\fP"
  1120. Many shells will echo the echo-off command when it is given. This
  1121. keyword tells PMake in what format the shell actually prints the
  1122. echo-off command. Wherever PMake sees this string in the shell's
  1123. output, it will delete it and any following whitespace, up to and
  1124. including the next newline. 
  1125. .IP "\fBechoFlag=\fP\fIflag to turn echoing on\fP"
  1126. The flag to pass to the shell to turn echoing on at the start.  If
  1127. either this or the next flag begins with a `\-', the flags will be
  1128. passed to the shell as separate arguments. Otherwise, the two will be
  1129. concatenated.
  1130. .IP "\fBerrFlag=\fP\fIflag to turn error checking on\fP"
  1131. Flag to give the shell to turn error checking on at the start.
  1132. .IP "\fBcheck=\fP\fIcommand to turn error checking on\fP"
  1133. The command to make the shell check for errors or to print the command
  1134. that's about to be executed (%s indicates where the command to print
  1135. should go), if hasErrCtl is "no".
  1136. .IP "\fBignore=\fP\fIcommand to turn error checking off\fP"
  1137. The command to turn error checking off or the command to execute a
  1138. command ignoring any errors. "%s" takes the place of the command.
  1139. .IP "\fBhasErrCtl=\fP\fIyes or no\fP"
  1140. This takes a value that is either
  1141. .B yes
  1142. or
  1143. .BR no ,
  1144. telling how the "check" and "ignore" commands should be used.
  1145. NOTE: If this is "no", both the check and ignore commands should
  1146. contain a \en at their end if the shell requires a newline before
  1147. executing a command.
  1148. .RE
  1149. .IP "\&" \n(pwu
  1150. The strings that follow these keywords may be enclosed in single or
  1151. double quotes (the quotes will be stripped off) and may contain the
  1152. usual C backslash-characters.
  1153. .IP .SILENT \n(pwu
  1154. Applies the
  1155. .B .SILENT
  1156. attribute to each of its sources. If there are no sources on the
  1157. dependency line, then it is as if you gave PMake the
  1158. .B \-s
  1159. flag.
  1160. .IP .SUFFIXES \n(pwu
  1161. This is used to give new file suffixes for PMake to handle. Each
  1162. source is a suffix PMake should recognize. If you give a
  1163. .B .SUFFIXES
  1164. dependency line with no sources, PMake will forget about all the
  1165. suffixes it knew (this also nukes the null suffix).
  1166. For those targets that need to have suffixes defined, this is how you do it.
  1167. .PP
  1168. In addition to these targets, a line of the form
  1169. .DS
  1170. \fIattribute\fP : \fIsources\fP
  1171. .DE
  1172. applies the
  1173. .I attribute
  1174. to all the targets listed as
  1175. .I sources
  1176. except as noted above.
  1177. .SH THE POWER OF SUFFIXES
  1178. .PP
  1179. One of the best aspects of both
  1180. .I Make
  1181. and
  1182. .Pm
  1183. comes from their understanding of how the suffix of a file pertains to
  1184. its contents and their ability to do things with a file based solely on its
  1185. suffix.
  1186. .Pm
  1187. also has the ability to find a file based on its suffix,
  1188. supporting different types of files being in different directories.
  1189. The former ability derives from the existence of so-called
  1190. transformation rules while the latter comes from the specification of
  1191. search paths using the
  1192. .B .PATH
  1193. target.
  1194. .SS TRANSFORMATION RULES
  1195. .PP
  1196. A special type of dependency, called a transformation rule, consists
  1197. of a target made of
  1198. two known suffixes stuck together followed by a shell script to transform a
  1199. file of one suffix into a file of the other.
  1200. The first suffix is the suffix of the source file and the second is that of
  1201. the target file.
  1202. E.g. the target ``.c.o,'' followed by commands,
  1203. would define a transformation from files with the
  1204. ``.c'' suffix to those with the ``.o'' suffix.
  1205. A transformation rule has no source files associated with it, though
  1206. attributes may be given to one in the usual way. These attributes are
  1207. then applied to any target that is on the ``target end'' of a
  1208. transformation rule.
  1209. The suffixes that are concatenated must be already known to
  1210. .Pm
  1211. in order for their concatenation to be recognized as a transformation,
  1212. i.e. the suffixes must have been the source for a .SUFFIXES target at some
  1213. time before the transformation is defined.
  1214. Many transformations are defined in the system makefile (qv.
  1215. .BR FILES )
  1216. and I refer you there for more examples as well as to find what is
  1217. already available (you should especially note the various variables
  1218. used to contain flags for the compilers, assemblers, etc., used to
  1219. transform the files. These variables allow you to customize the
  1220. transformations to your own needs without having to redefine them).
  1221. A transformation rule may be defined more than once, but only the last
  1222. such definition is remembered by
  1223. .Pm .
  1224. This allows you to redefine the transformations in the system makefile if
  1225. you wish.
  1226. .PP
  1227. Transformation rules are used only when a target has no commands associated
  1228. with it,
  1229. both to find any additional files on which it depends and to attempt to
  1230. figure out just how to make the target should it end up being out-of-date.
  1231. When a transformation is found for a target, another of the seven ``local''
  1232. variables mentioned earlier is defined:
  1233. .RS
  1234. .IP ".IMPSRC (<)"
  1235. The name/path of the source from which the target is to be transformed (the
  1236. ``implied'' source).
  1237. .RE
  1238. .PP
  1239. For example,
  1240. given the following makefile:
  1241. .DS
  1242. a.out : a.o b.o
  1243.     $(CC) $(.ALLSRC)
  1244. .DE
  1245. and a directory containing the files a.o, a.c and b.c,
  1246. .Pm
  1247. will look at the list of suffixes and transformations given in the
  1248. built-in rules and find that the suffixes ``.c'' and ``.o'' are both
  1249. known and there is a transformation rule defined from one to the other
  1250. with the command ``$(CC) $(CFLAGS) -c $(.IMPSRC).''  Having found
  1251. this, it can then check the modification times of both a.c and b.c and
  1252. execute the command from the transformation rule as necessary in order
  1253. to update the files a.o and b.o.
  1254. .PP
  1255. .Pm ,
  1256. unlike
  1257. .I Make
  1258. before it,
  1259. has the ability to apply several transformations to a file even if the
  1260. intermediate files do not exist.
  1261. Given a directory containing a .o file and a .q file, and transformations
  1262. from .q to .l, .l to .c and .c to .o,
  1263. .Pm
  1264. will define a transformation from .q \*(-> .o using the three transformation
  1265. rules you defined.
  1266. In the event of two paths between the same suffixes, the shortest path will be
  1267. chosen between the target and the first existing file on the path.
  1268. So if there were also a transformation from .l files to .o files,
  1269. .Pm
  1270. would use the path .q \*(-> .l \*(-> .o instead
  1271. of .q \*(-> .l \*(-> .c \*(-> .o.
  1272. .PP
  1273. Once an existing file is found,
  1274. .Pm
  1275. will continue to look at and record transformations until it comes to a
  1276. file to which nothing it knows of can be transformed,
  1277. at which point it will stop looking and use the path it has already found.
  1278. .PP
  1279. What happens if you have a .o file, a .q file and a .r file, all with
  1280. the same prefix, and transformations from .q \*(-> .o and .r \*(-> .o?
  1281. Which transformation will be used?
  1282. .Pm
  1283. uses the order in which the suffixes were given on the
  1284. .B .SUFFIXES
  1285. line to decide between transformations: whichever suffix came first,
  1286. wins.
  1287. So if the three suffixes were declared
  1288. .DS
  1289. \&.SUFFIXES : .o .q .r
  1290. .DE
  1291. the .q \*(-> .o transformation would be applied. Similarly, if they were
  1292. declared as
  1293. .DS
  1294. \&.SUFFIXES : .o .r .q
  1295. .DE
  1296. the .r \*(-> .o transformation would be used.
  1297. You should keep this in mind when writing such rules.
  1298. Note also that because the placing of a suffix on a
  1299. .B .SUFFIXES
  1300. line doesn't alter the precedence of previously-defined
  1301. transformations,
  1302. it is sometimes necessary to clear the whole lot of them out and start
  1303. from scratch. This is what the
  1304. .BR .SUFFIXES -only
  1305. line, mentioned earlier, will do.
  1306. .SH SEARCH PATHS
  1307. .PP
  1308. .Pm
  1309. also supports the notion of multiple directories in a more flexible,
  1310. easily-used manner than has been available in the past.
  1311. You can define a list of directories in which to search for any and
  1312. all files that aren't in the current directory by giving the directories
  1313. as sources to the
  1314. .B .PATH
  1315. target. The search will only be conducted for those files used only as
  1316. sources, on the assumption that files used as targets will be created
  1317. in the current directory.
  1318. .PP
  1319. The line
  1320. .DS
  1321. \&.PATH : RCS
  1322. .DE
  1323. would tell
  1324. .Pm
  1325. to look for any files it is seeking (including ones made up by means
  1326. of transformation rules) in the RCS directory as well as the current
  1327. one. Note, however, that this searching is only done if the file is
  1328. used only as a source in the makefile. I.e. if the file cannot be
  1329. created by commands in the makefile.
  1330. .PP
  1331. A search path specific to files with a given suffix can also be
  1332. specified in much the same way.
  1333. .DS
  1334. \&.PATH.h : h /sprite/lib/include
  1335. .DE
  1336. causes the search for header files to be conducted in the h and
  1337. /sprite/lib/include directory as well as the current one.
  1338. .PP
  1339. When expanding wildcards, these paths are also used. If the pattern
  1340. has a recognizable suffix, the search path for that suffix is used.
  1341. Otherwise, the path defined with the regular
  1342. .B .PATH
  1343. target is used.
  1344. .PP
  1345. When a file is found somewhere other than the current directory, its
  1346. name is replaced by its full pathname in any ``local'' variables.
  1347. .PP
  1348. Two types of suffixes are given special attention when a search path is defined
  1349. for them. On most systems, the C compiler lets you specify where to
  1350. find header files (.h files) by means of
  1351. .B \-I
  1352. flags similar to those used by
  1353. .Pm .
  1354. If a search path is given for any suffix used as a source for the
  1355. .B .INCLUDES
  1356. target, the variable
  1357. .B $(.INCLUDES)
  1358. will be set to contain all the directories on the path, in the order
  1359. given, in a format which can be passed directly to the C compiler.
  1360. Similarly, on some systems, one may give directories to search for
  1361. libraries to the compiler by means of
  1362. .B \-L
  1363. flags.
  1364. Directories on the search path for a suffix which was the source of the
  1365. .B .LIBS
  1366. target will be placed
  1367. in the
  1368. .B $(.LIBS)
  1369. variable ready to be passed to the compiler.
  1370. .SH LIBRARIES AND ARCHIVES
  1371. .PP
  1372. Two other special forms of sources are recognized by
  1373. .Pm .
  1374. Any source that begins with the characters ``-l'' or ends in a suffix
  1375. that is a source for the
  1376. .B .LIBS
  1377. target is assumed to be a library, and any source that contains a left
  1378. parenthesis in it is considered to be a member (or members) of an archive.
  1379. .PP
  1380. Libraries are treated specially mostly in how they appear in the local
  1381. variables of those targets that depend on them. If the system supports the
  1382. .B \-L
  1383. flag when linking, the name of the library (i.e. its ``-l'' form) is
  1384. used in all local variables.
  1385. .Pm
  1386. assumes that you will use the $(.LIBS) variable in the appropriate place.
  1387. If, however, the system does not have this feature, the name is
  1388. expanded to its full pathname before it is placed in any local
  1389. variable.
  1390. .PP
  1391. One problem with libraries is they have a table of contents in them
  1392. and when the file is touched (so the file's modification time and the
  1393. time listed in the table of contents don't match), the library is
  1394. declared to be ``out-of-date'' by the linker and the final linking
  1395. stage of creating your program fails miserably. To avoid this problem,
  1396. when you use the
  1397. .B \-t
  1398. flag,
  1399. .Pm
  1400. updates the time of the table of contents for the library, as well as
  1401. the library itself.
  1402. .PP
  1403. The process of creating a library or archive can be a painful one,
  1404. what with all the members having to be kept outside the archive as
  1405. well as inside it in order to keep them from being recreated.
  1406. .Pm
  1407. has been set up, however, to allow you to reference files that are in
  1408. an archive in a relatively painless manner.
  1409. The specification of an archive member is written as:
  1410. .DS
  1411. \fIarchive\fP(\fImember\fP [\fImember\fP...])
  1412. .DE
  1413. Both the open and close parenthesis are required and there may be any
  1414. number of members between them (except 0, that is). Members may also
  1415. include wildcards characters.  When such a source is examined, it is
  1416. the modification time of the member, as recorded in the archive, that
  1417. is used to determine its datedness.
  1418. .PP
  1419. If an archive member has no commands associated with it,
  1420. .Pm
  1421. goes through a special process to find commands for it.
  1422. First, implicit sources are sought using the ``member'' portion of the
  1423. specification. So if you have something like
  1424. ``libcompat.a(procFork.o)'' for a target,
  1425. .Pm
  1426. attempts to find sources for the file ``procFork.o,'' even if it
  1427. doesn't exist. If such sources exist,
  1428. .Pm
  1429. then looks for a transformation rule from the member's suffix to the
  1430. archive's (in this case from .o \*(-> .a) and tacks those commands on
  1431. as well.
  1432. .PP
  1433. To make these transformations easier to write,
  1434. three local variables are defined for the target:
  1435. .IP ".ARCHIVE (%)
  1436. The path to the archive file.
  1437. .IP ".MEMBER (!)
  1438. The actual member name (literally the part in parentheses).
  1439. .IP ".TARGET (@@)
  1440. The path to the file which will be archived, if it is only a source,
  1441. or the same as the 
  1442. .B .MEMBER
  1443. variable if it is also a target.
  1444. .PP
  1445. Using the transformations already in the system makefile, a makefile
  1446. for a library might look something like this:
  1447. .DS
  1448. OBJS = procFork.o procExec.o procEnviron.o fsRead.o
  1449. \&.o.a :
  1450.     ...
  1451.     rm -f $(.MEMBER)
  1452.  
  1453. lib.a : lib.a($(OBJS))
  1454.     ar cru $(.TARGET) $(.OODATE)
  1455.     ranlib $(.TARGET)
  1456. .DE
  1457. .PP
  1458. You might be wondering,
  1459. at this point,
  1460. why I did not define the .o \*(-> .a transformation like this:
  1461. .DS
  1462. \&.o.a :
  1463.     ar r $(.ARCHIVE) $(.TARGET)
  1464.     ...
  1465.     rm -f $(.TARGET)
  1466. .DE
  1467. The reason is simple: you cannot execute ``ar'' on the same file
  1468. several times at once. If you try, you end up with a corrupted
  1469. archive.
  1470. So rather than reduce
  1471. .Pm
  1472. to executing only one job at a time, I chose to archive all the
  1473. out-of-date files at once (this turns out to be faster anyway).
  1474. .SH OUTPUT
  1475. .PP
  1476. When creating targets in parallel,
  1477. several shells are executing at once,
  1478. each wanting to write its own two cent's worth onto the screen.
  1479. This output must be captured by
  1480. .Pm
  1481. in some way in order to prevent the screen from being filled with
  1482. garbage even more indecipherable than one can already get from these programs.
  1483. .Pm
  1484. has two ways of doing this,
  1485. one of which provides for much cleaner output and a clear delineation between
  1486. the output of different jobs,
  1487. the other of which provides a more immediate response so one can tell what is
  1488. really happening.
  1489. The former is done by notifying the user when the creation of a given target
  1490. starts, capturing the output, and transferring it
  1491. to the screen when the job finishes,
  1492. preceded by an indication as to which job produced the output.
  1493. The latter is done by catching the output of the shell (and its children)
  1494. and buffering it until an entire line is received, then printing
  1495. that line preceded by the name of the job from which the line came.
  1496. The name of the job is just the target which is being created by it.
  1497. Since I prefer this second method,
  1498. it is the one used by default.
  1499. The first method will be used if the
  1500. .B \-P
  1501. flag is given to
  1502. .Pm .
  1503. .SH PARALLELISM
  1504. .PP
  1505. As mentioned before,
  1506. .Pm
  1507. attempts to create several targets at once.
  1508. On some systems where load balancing or process migration is in
  1509. effect, the amount of concurrency which can be used will be much
  1510. greater than on others. During the development of
  1511. .Pm ,
  1512. I found that while one could create up to five targets at once on a
  1513. Sun 3 without making the machine unusable, attempting the same feat
  1514. on a Sun 2 would grind the machine into the dirt, most likely making
  1515. the whole process run slower than it would have under
  1516. .IR Make .
  1517. In addition, the use of
  1518. .Pm
  1519. on a multi-user machine (in contrast to a workstation) calls for
  1520. judicious use of concurrency to avoid annoying the other users. The
  1521. ability to execute tasks in parallel, in combination with the
  1522. execution of only one shell per target, brings about decreases in
  1523. creation time on the order of 25%\-60%.
  1524. .PP
  1525. The
  1526. .B \-J
  1527. and
  1528. .B \-L
  1529. flags are used to control the number of shells executing at once and
  1530. should be used to find the best level for your machine. Once this is
  1531. found, the default level can be set at that point and
  1532. .Pm
  1533. recompiled.
  1534. .SH BACKWARD-COMPATIBILITY
  1535. .PP
  1536. .Pm
  1537. was designed to be as backwards-compatible with
  1538. .I Make
  1539. as possible.
  1540. In spite of this, however, there are a few major differences which may
  1541. cause problems when using old makefiles:
  1542. .IP 1)
  1543. The variable substitution, as mentioned earlier, is very different and
  1544. will cause problems unless the makefile is converted or the
  1545. .B \-V
  1546. flag is given.
  1547. .IP 2)
  1548. Because targets are created in parallel, certain sequences which
  1549. depend on the sources of a target being created sequentially will fail
  1550. miserably. E.g.:
  1551. .DS
  1552. prod : $(PROGRAM) clean
  1553. .DE
  1554. This is liable to cause some of the object files to be removed after
  1555. having been created during the current invocation (or, at the very
  1556. least, the object files will not be removed when the program has been
  1557. made), leading to errors in the final linking stage. This problem
  1558. cannot even be gotten around by limiting the maximum concurrency to
  1559. one, since the traversal of the dependency graph is done in a
  1560. breadth-first, rather than a depth-first way. This can only be gotten
  1561. around by rewriting the makefile, or by invoking
  1562. .Pm
  1563. with the
  1564. .B \-M
  1565. flag.
  1566. .PP
  1567. One other possible conflict arises because
  1568. .Pm
  1569. forks only one shell to execute the commands to re-create a target.
  1570. This means that changes of directory, environment, etc., remain in
  1571. effect throughout the creation process. It also allows for a more
  1572. natural entry of shell constructs, such as the ``for'' and ``while''
  1573. loops in the Bourne shell, without the need for backslashes and
  1574. semi-colons required by the one-shell-per-command paradigm used by
  1575. .IR Make .
  1576. This shouldn't pose any serious difficulties (or even any trivial ones
  1577. so far as I can see), but should,
  1578. in fact,
  1579. make life a little easier. It is, however, possible to have
  1580. .Pm
  1581. execute each command in a single shell by giving it the
  1582. .B \-B
  1583. flag.
  1584. .SH FILES
  1585. .ta \w'/sprite/lib/pmake/sys.mk  'u
  1586. Makefile or makefile    default input file
  1587. .br
  1588. /sprite/lib/pmake/sys.mk    System makefile (the built-in rules)
  1589. .SH ENVIRONMENT
  1590. .ta \w'\fBPMAKE\fP    'u
  1591. \fBPMAKE\fP    Flags PMake should always use when invoked.
  1592. .SH SEE ALSO
  1593. .IR make (1)
  1594. for a more complete explanation of the lower-case flags to
  1595. .Pm .
  1596. .SH KEYWORDS
  1597. make, transformation
  1598. .SH AUTHOR
  1599. Adam de Boor
  1600. @
  1601.  
  1602.  
  1603. 1.6
  1604. log
  1605. @Change revision date.
  1606. @
  1607. text
  1608. @d1 1
  1609. a1 1
  1610. '\" $Id: pmake.man,v 1.5 91/02/04 13:54:38 kupfer Exp Locker: kupfer $ SPRITE (Berkeley)
  1611. d108 21
  1612. a128 2
  1613. is a string of letters from the following set: a, c, d, j, m, p, r, s,
  1614. t, v.  Use
  1615. @
  1616.  
  1617.  
  1618. 1.5
  1619. log
  1620. @Explain how to find out what host each job is run on.
  1621. @
  1622. text
  1623. @d1 1
  1624. a1 1
  1625. '\" $Id: pmake.man,v 1.4 90/08/02 14:06:34 douglis Exp Locker: kupfer $ SPRITE (Berkeley)
  1626. d21 1
  1627. a21 1
  1628. .HS PMAKE cmds "17 February 1990"
  1629. @
  1630.  
  1631.  
  1632. 1.4
  1633. log
  1634. @toggled meaning of verboseRemigrates flag (default now off).
  1635.  
  1636. @
  1637. text
  1638. @d1 1
  1639. a1 1
  1640. '\" $Id: pmake.man,v 1.3 90/06/28 22:31:48 douglis Exp Locker: douglis $ SPRITE (Berkeley)
  1641. d108 4
  1642. a111 1
  1643. is a string of letters from the following set: a, c, d, j, m, p, r, s, t, v.
  1644. @
  1645.  
  1646.  
  1647. 1.3
  1648. log
  1649. @described -b/.BACKGROUND and -R (quietly remigrate) options.
  1650. @
  1651. text
  1652. @d1 1
  1653. a1 1
  1654. '\" $Id: pmake.man,v 1.2 90/06/26 22:08:36 douglis Exp Locker: douglis $ SPRITE (Berkeley)
  1655. d203 1
  1656. a203 1
  1657. ``Remigrate quietly'' -- do not announce when processes are remigrated
  1658. @
  1659.  
  1660.  
  1661. 1.2
  1662. log
  1663. @sprite-ified it a bit, and changed doc relating to migration/export.
  1664. (this change dates to last march -- another change to be added after this
  1665. check-in.)
  1666. @
  1667. text
  1668. @d1 1
  1669. a1 1
  1670. '\" $Id: pmake.man,v 1.1 90/02/17 17:15:23 douglis Exp Locker: douglis $ SPRITE (Berkeley)
  1671. d30 2
  1672. d83 2
  1673. d102 3
  1674. d202 3
  1675. d804 3
  1676. d903 6
  1677. @
  1678.  
  1679.  
  1680. 1.1
  1681. log
  1682. @Initial revision
  1683. @
  1684. text
  1685. @d1 1
  1686. a1 1
  1687. '\" $Id: pmake.mansp,v 1.5 89/02/05 18:08:23 adam Exp $ SPRITE (Berkeley)
  1688. d20 2
  1689. a21 1
  1690. .TH PMAKE prog "21 January 1989"
  1691. d23 1
  1692. a23 1
  1693. .NA
  1694. d25 1
  1695. a25 1
  1696. .SY
  1697. d57 2
  1698. a60 2
  1699. .B \-v\c
  1700. ] [\c
  1701. a151 5
  1702. .AP \-x "\&"
  1703. ``Export'' -- causes commands to be exported when in
  1704. Make-compatibility mode. Since exporting commands in this mode will
  1705. often take longer than running them on the local machine, exportation
  1706. is off by default and must be turned on using this flag.
  1707. d155 7
  1708. d202 1
  1709. a202 2
  1710. ``No Export'' -- prohibits exportation. \-x and \-X should not be used
  1711. in the same command.
  1712. d1239 1
  1713. a1239 1
  1714. \&.PATH.h : h /usr/include
  1715. d1242 1
  1716. a1242 1
  1717. /usr/include directory as well as the current one.
  1718. d1490 1
  1719. a1490 1
  1720. .ta \w'/usr/public/lib/pmake/sys.mk  'u
  1721. d1493 1
  1722. a1493 1
  1723. /usr/public/lib/pmake/sys.mk    System makefile (the built-in rules)
  1724. @
  1725.